{include file="index/header" /}
<link rel="stylesheet" type="text/css" href="__PUBLIC__css/jedate.css">
<script type="text/javascript" src="__PUBLIC__js/jquery.jedate.min.js"></script>
<body>
	<div class="panel admin-panel">
		<form method="post" action="" id="listform">
			<div class="panel-head"><strong class="icon-reorder"> 内容列表 <font>今日注册（<span class="todayNum">{$todayNum}</span>）个  新增（<span class="todayNewNum">{$todayNewNum}</span>）个</font></strong></div>
			<div class="padding border-bottom">
				<ul class="search" style="padding-left:10px;">
					<li>
						<li>
							<input type="text" placeholder="开始日期" id="test" name="start_time" value="{$param.start_time}" class="input jcDate" style="width:110px; line-height:17px;display:inline-block" AUTOCOMPLETE="OFF"/> -
							<input type="text" placeholder="结束日期" id="test" name="end_time" value="{$param.end_time}" class="input jcDate" style="width:110px; line-height:17px;display:inline-block" AUTOCOMPLETE="OFF"/>
							<input type="search" placeholder="手机号/邮箱" name="phone" value="{$param.phone}" class="input"  style="width:250px; line-height:17px;display:inline-block;"/>
						</li>
						<a href="javascript:void(0)" class="button border-main" onclick="changesearch()">搜索用户</a>
					</ul>
				</div>
				<table class="table table-hover text-center text-center1">
					<tr>
						<th>序号</th>
						<th>用户ID</th>
						<th>昵称</th>
						<th>手机号</th>
						<th width="30%">会员身份</th>
						<th>成为会员时间</th>
						<th>注册时间</th>
						<th>注册来源</th>
						<th>操作</th>
					</tr>
					{foreach name='user_data' item='v' key='k'}
					<tr class="tr2">
						<td>{$k+1}</td>
						<td><input type="checkbox" name="user_id[]" value="{$v.know_user_id}" />{$v.know_user_id}</td>
						<td>{$v.know_nickname}</td>
						<td>{if $v.know_phone}{$v.know_phone}{else}{$v.know_email}{/if}</td>
						<td width="30%">{$v.type}</td>
						<td>{$v.vipTime}</td>
						<td>{$v.register_time}</td>
						<td>{if $v.action eq 0}PC{elseif $v.action eq 1}手机{else}小程序{/if}</td>
						<td><div class="button-group"> {if $admin['role_id'] eq 1}<a class="button border-main" href="{:url('nav_price',['id' => $v['know_user_id'],'page'=>$page,'phone'=>$param['phone'],'start_time'=>$param['start_time'],'end_time'=>$param['end_time']])}"><span class="icon-edit"></span>设置用户身份</a>{/if}<a class="button border-main" href="{:url('detail',['id' => $v['know_user_id']])}">查看详情</a></div></td>
					</tr>
					{/foreach}
				</table>
				<table class="table table-hover text-center"><tr>
						<td colspan="9" align="left"><input type="checkbox" id="checkall"/>
						全选 </td>
					</tr>
				<tr><td colspan="9">{$user_data->render()}</td></tr></table>
			</div>
		</form>
		<audio id="audio" src="/public/neworder.mp3"></audio>
	</body></html>
<script>
//全选
$("#checkall").click(function(){ 
	$("input[name='user_id[]']").each(function(){
		if (this.checked) {
			this.checked = false;
		}
		else {
			this.checked = true;
		}
	});
});
$(".jcDate").jeDate({
	format:"YYYY-MM-DD",
	isTime:false, 
	minDate:"2014-09-19 00:00:00"
});
function render(){
	_ts = $(this);
	$.ajax({
		url:"{:url('getToday')}",
		dataType:'json',
		success:function(data){
			$('.tr2').remove();
			var todayNewNum = $('.todayNewNum').text();
			if(todayNewNum != data.todayNewNum) playSound();
			$('.todayNewNum').text(data.todayNewNum);
			$('.todayNum').text(data.todayNum);
			$.each(data.userData,function(i,val){
				var phone = val.know_phone ? val.know_phone : val.know_email;
				switch(val.action) {
					case '0':
					var action = 'PC';
					break;
					case '1':
					var action = '手机';
					break;
					default:
					var action = '小程序';
				}
				if(val.vipTime == null) val.vipTime = '';
				var userIds = ''
				if(data.roleId == 1) var userIds = '<a class="button border-main" href="/admin/user/nav_price/id/'+val.know_user_id+'.html"><span class="icon-edit"></span>设置用户身份</a>';
				$('.text-center1').append('<tr class="tr2_'+(i+1)+'"><td>'+(i+1)+'</td><td><input type="checkbox" name="user_id[]" value="'+val.know_user_id+'" />'+val.know_user_id+'</td><td>'+val.know_nickname+'</td><td>'+phone+'</td><td width="30%">'+val.type+'</td><td>'+val.vipTime+'</td><td>'+val.register_time+'</td><td>'+action+'</td><td><div class="button-group">'+userIds+' <a class="button border-main" href="/admin/user/detail/id/'+val.know_user_id+'.html">查看详情</a></div></td></tr>');
			});
		}
	})
}
var interval=setInterval("render()",3000*60);
</script>
<script>
	var playSound = function () {
		var audioEle = document.getElementById("audio");
		audioEle.load();
		audioEle.play();
	}
</script>